function preload(datalist,maxTime){
	this.datalist = datalist;
	this.loaded = 0;
	this.totalNum = this.datalist.length;
	this.per = "0%";
	this.maxTime = maxTime;
	this.timer  = null;
	this.isCom = false;
}

preload.prototype.starload = function(){
	var outlineTime = parseFloat(this.maxTime);
	var self = this;
	if(!isNaN(outlineTime)){
		this.timer = setTimeout(function(){
			if(!self.isCom){
				self.isCom = true;
				self.onError();
				return ;
			}
		},outlineTime*1000);
	}
	for(var k in this.datalist){
		//创建图片对象
		var temImg = new Image();
		temImg.onload = function(){
			self.loadFun();
		};
		temImg.onerror = function(){
			self.loadFun();
		};
		console.log(this.datalist[k]);
		//填充图片
		temImg.src = this.datalist[k];
		if(temImg.complete){
			this.loadFun();
		}
	}
}
preload.prototype.loadFun = function(){
	this.loaded++;
	this.per = Math.ceil(this.loaded/this.totalNum*100)+"%";
	if(this.loaded>=this.totalNum){
		//清除定时器
		clearTimeout(this.timer);
		this.onError;
		this.onComplete();
	}
}

preload.prototype.onComplete = function(){
	var imgs = document.images;
	for(var i = 0;i<imgs.length;i++){
		imgs[i].src = datalist[i];
		imgs[i].style.display = "block";
		imgs[i].parentElement.classList.add("active");
		document.querySelector(".load_btn").classList.add("active");
	}
}

preload.prototype.onError = function(){
	alert("网络错误!");
}
